package org.geometerplus.zlibrary.ui.android.image;

import org.geometerplus.zlibrary.core.image.ZLImage;
import org.geometerplus.zlibrary.core.image.ZLImageManager;
import org.geometerplus.zlibrary.core.image.ZLLoadableImage;
import org.geometerplus.zlibrary.core.image.ZLSingleImage;
import org.geometerplus.zlibrary.core.util.MimeType;

public final class ZLAndroidImageManager extends ZLImageManager {
	@Override
	public ZLAndroidImageData getImageData(ZLImage image) {
		if (image instanceof ZLSingleImage) {
			final ZLSingleImage singleImage = (ZLSingleImage)image;
			if (MimeType.IMAGE_PALM.equals(singleImage.mimeType())) {
				return null;
			}
			return new InputStreamImageData(singleImage);
		} else {
			// TODO
			return null;
		}
	}

	private ZLAndroidImageLoader myLoader;

	@Override
	protected void startImageLoading(ZLLoadableImage image, Runnable postLoadingRunnable) {
		if (myLoader == null) {
			myLoader = new ZLAndroidImageLoader();
		}
		myLoader.startImageLoading(image, postLoadingRunnable);
	}
}
